#ifndef _S_CCS811_H_
#define _S_CCS811_H_

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define S_CCS811_nWake_PIN              IOID_9
#define S_CCS811_nInt_PIN               IOID_10
#define S_CCS811_nReset_PIN             IOID_11
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

#define S_CCS811_ADDR                   (0x5A << 1)

#define S_CCS811_STATUS                 0x00
#define S_CCS811_STATUS_ERROR           (1 << 0)
#define S_CCS811_STATUS_DATA_READY      (1 << 3)
#define S_CCS811_STATUS_APP_VALID       (1 << 4)
#define S_CCS811_STATUS_FM_MODE         (1 << 7)
#define S_CCS811_STATUS_MEASTHRE        0x9A

#define S_CCS811_MEAS_MODE              0x01
#define S_CCS811_MEAS_MODE_DEFAULT      0x10//0x18//0x10

#define S_CCS811_ALG_RESULT_DATA        0x02
#define S_CCS811_ALG_RESULT_DATA_LEN    0x08

#define S_CCS811_ENV_DATA				0x05
#define S_CCS811_ENV_DATA_LEN			0x04

#define S_CCS811_HW_ID_REG              0x20
#define S_CCS811_HW_ID_VALUE            0x81

#define S_CCS811_APP_START              0xF4

#define S_CCS811_SW_RESET               0xFF

#define S_CCS811_TVOC_MIN				0
#define S_CCS811_TVOC_MAX				32768

#define S_CCS811_eCO2_MIN				400
#define S_CCS811_eCO2_MAX				29206

typedef struct s_ccs811_data_t
{
    unsigned int eCO2;
    unsigned int TVOC;
    unsigned char status;
    // unsigned short temp;
    // unsigned short humi;
    unsigned char hwID;
    unsigned char errorID;
}s_ccs811_data_t;


extern s_ccs811_data_t ccs811_t;

extern char s_ccs811_out_data[50];
extern signed short s_ccs811_out_data_len;

extern void S_CCS811_Test(void);
extern signed char s_ccs811_getAlgResultData(s_ccs811_data_t *ccs811_t);
extern signed char S_CCS811_PinInit(void);

#endif
